#include <stdio.h>
#include <string.h>

char ss[20];
int len;
unsigned int tot;
int value[10];

bool in()
{
    scanf("%s", ss);
    if (strlen(ss)==1 && ss[0] == '0')
         return false;
    return true;
}    
void deal()
{
    int i, j;
    tot = 0;
    len = strlen(ss);
    j = 1;
    for (i=len-1; i>=0; --i)
    {
        tot += value[ss[i]-'0']*j;
        j *=9;
    }    
    printf("%s: %d\n", ss, tot);
}    
int main()
{
    int i;
    for (i=0; i<=4; ++i) value[i] = i;
    for (i=5; i<=9; ++i) value[i] = i-1;
    while (in())
    {
        deal();
    }    
 
    return 0;       
}    
